package com.edu.html.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.edu.common.controller.BaseController;
import com.edu.common.utils.JsonUtils;
import com.edu.html.pojo.Books;
import com.edu.html.service.BookService;

@Controller
@RequestMapping("/html/")
public class BookController extends BaseController{
	
	@Autowired
	private BookService bookService;

	/*@Autowired
	private MongoDBService mongodbService;*/
	
	@RequestMapping("sec/getbook.shtml")
	@ResponseBody
	public Map<String,Object> getBook(HttpServletRequest request,@RequestParam(value="id",required=false,defaultValue="1") String id){
		Map<String,Object> result = new HashMap<String, Object>();
		try {
			Books book =  bookService.getBook(id);
//			mongodbService.save(JsonUtils.obj2json(book));
			result.put("book", book);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}
	
	
}
